package com.lanswon.icc.admin.controller;

import com.lanswon.icc.admin.service.UserService;
import com.lanswon.icc.admin.vo.ViewUserVo;
import com.lanswon.icc.common.core.dto.UserInfo;
import com.lanswon.icc.common.core.vo.Result;
import com.lanswon.icc.common.security.annotation.Inner;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/user")
@RestController
@AllArgsConstructor
public class Usercontroller {
   private final UserService userService;


    /**
     * 获取当前用户全部信息
     *
     * @return 用户信息
     */
    @GetMapping(value = "info")
    public Result info() {
        ViewUserVo viewUserVo = userService.currentUserInfo();
        return  Result.success(viewUserVo);

    }




    /**
     * 权限认证，此接口
     * @param username
     * @return
     */

    @Inner
    @GetMapping("/info/{username}")
    public Result<UserInfo> findByUsername(@PathVariable(value = "username") String username) {
        UserInfo userInfo = userService.findByUsername(username);

        return  Result.success(userInfo);

    }




    /**
     * 根据lanswon.icc查询用户信息
     *
     * @param username 用户名
     * @return
     */
    @GetMapping("/details/{username}")
    public Result user(@PathVariable String username) {
        return Result.success(userService.findSysUserByUsername(username));
    }


}
